Use of Object Identifier

Hello..
Just a quick doubt. Is it possible to get a handle on an object in an open module by using the Object Identifier or is the Absolute Number necessary.
I am not seeing any way that the Object Identifier can be used to find the object. Any idea?

Regards,
Jyothi
jnbharadhwaj - Wed Aug 22 02:42:53 EDT 2012

Re: Use of Object Identifier
Mathias Mamsch - Wed Aug 22 04:13:17 EDT 2012

Well the obvious way to find an object using the object identifier is to search the object:
 

string s;
Object o, oResult = null; 
for o in entire mod do {
   if (isDeleted o || cell o || row o || table o) continue // exclude whatever applicable
   s = identifier o 
   if (s == "TBD_123") { oResult = o; break }
}

 


However since we can safely assume that the identifier is a combination of prefix and absolute number we can also do this quicker variant:

 

 

 

string sPrefix = mod."Prefix" // TBD_
string sSearch = "TBD_123"
 
int absNoToSearch = intOf realOf sSearch[length sPrefix:]
 
// using object you will get 90% of the objects very quickly in the normal case
Object oResult = object absNoToSearch 
 
// since object only covers visible objects, still do a search if it returns null
if (null oResult) {
    Object oSearch;
    for oSearch in entire mod do {
      if (isDeleted ...) { continue }
      int nr = oSearch."Absolute Number" 
      if (nr == absNoToSearch) { oResult = oSearch; break }
    }
}



Hope this helps, regards, Mathias



 

 

 


Mathias Mamsch, IT-QBase GmbH, Consultant for Requirement Engineering and D00RS

 

Re: Use of Object Identifier
llandale - Wed Aug 22 10:06:13 EDT 2012

That "object(AbsNo)" command puts you at the mercy of the current view; that for me makes it useless.

Browsing the module for a single object is OK, but if you figure to do it lots of times then it takes quite a long time. Instead consider this:

Skip skpObjects = createString() // KEY: 'string' ObjID: DATA: 'Object' handle
for o in entire mod do
{  if (isDeleted(o)) continue
   if (I don't care about o) then continue
   put(skpObjects, identifier(o), o)
}
later on ...
if (!find(skpObjects, TargetIdentifier, o)) then error
else
{ deal with target Object o
}
...
delete(skpObjects)


I've written a rather elaborate set of "fObject_find()" functions that keep track of search Skip lists for "N" different Modules. User programs simply issue "Object oTarget = fObject_find(ID)" and the internals load the Skip if needed.

-Louie

I'm going to get new breaks if the current ones work a whopping 99% of the time.

Re: Use of Object Identifier
Mathias Mamsch - Thu Aug 23 04:08:04 EDT 2012

llandale - Wed Aug 22 10:06:13 EDT 2012

That "object(AbsNo)" command puts you at the mercy of the current view; that for me makes it useless.

Browsing the module for a single object is OK, but if you figure to do it lots of times then it takes quite a long time. Instead consider this:

Skip skpObjects = createString() // KEY: 'string' ObjID: DATA: 'Object' handle
for o in entire mod do
{  if (isDeleted(o)) continue
   if (I don't care about o) then continue
   put(skpObjects, identifier(o), o)
}
later on ...
if (!find(skpObjects, TargetIdentifier, o)) then error
else
{ deal with target Object o
}
...
delete(skpObjects)


I've written a rather elaborate set of "fObject_find()" functions that keep track of search Skip lists for "N" different Modules. User programs simply issue "Object oTarget = fObject_find(ID)" and the internals load the Skip if needed.

-Louie

I'm going to get new breaks if the current ones work a whopping 99% of the time.

The object function is far from useless. If it gives you the correct object for 95% of the time, then you only need to search for the object 5% of the times. This gives you acceptable performance in most cases. Although you are right, that caching the objects in a skip is much faster, however you always need to take care of your cache being up-to-date. Creating objects, closing and reopening modules will invalidate the cache, therefore I guess the approach that one takes, depends on the use case. Regards, Mathias


Mathias Mamsch, IT-QBase GmbH, Consultant for Requirement Engineering and D00RS

Re: Use of Object Identifier
llandale - Thu Aug 23 10:28:27 EDT 2012

Mathias Mamsch - Thu Aug 23 04:08:04 EDT 2012
The object function is far from useless. If it gives you the correct object for 95% of the time, then you only need to search for the object 5% of the times. This gives you acceptable performance in most cases. Although you are right, that caching the objects in a skip is much faster, however you always need to take care of your cache being up-to-date. Creating objects, closing and reopening modules will invalidate the cache, therefore I guess the approach that one takes, depends on the use case. Regards, Mathias


Mathias Mamsch, IT-QBase GmbH, Consultant for Requirement Engineering and D00RS

Ah HA! But I've also got a clever dynamic trigger that keeps track of the "session" of the open module, and if the trigger doesn't exist or the session is not correct, then I know the user has closed and re-opened the module and my caches are invalid.

You seem to forget I get really carried away!

I guess I'll do some timing testing on the "object" function; but still it only works for AbsNo and Identifier searches, not the more general "Key field" searches (such as "Document Number").

-Louie